import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import DetailView from '@/detail/detailView.vue'
import SearchView from '@/search/searchView.vue'
import PersonalView from '@/personal/personalView.vue'
import CarView from '@/car/CarView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/detail',
    name: 'detail',
    component: DetailView,
  },
  {
    path: '/search',
    name: 'search',
    component: SearchView
  }, 
   {
    path: '/personal',
    name: 'personal',
    component: PersonalView
  },
  {
    path: '/car',
    name: 'car',
    component: CarView
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// router.beforeEach((to, from, next) => {
//   if (to.name !== 'LoginView1') {
//     if (localStorage.getItem('vuex')) {
//       next()
//     }else {
//       next({
//         name: 'LoginView1',
//       })
//     }
//   } else {
//     next()
//   }
// })
export default router
